package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.CleaningStrategy;
import com.zygh.interactiveplatform.module.entity.CleaningStrategy;
import com.zygh.interactiveplatform.module.service.CleaningStrategyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-02-03
 */
@RestController
@RequestMapping("/cleaning-strategy")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_CLEANINGSTRATEGY})
public class CleaningStrategyController {
    @Resource
    private CleaningStrategyService cleaningStrategyService;

    @ApiOperation(value = "清洗策略新增", notes = "清洗策略新增")
    @PostMapping("addCleaningStrategye")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_CLEANINGSTRATEGY, content = "清洗策略新增")
    public ResponseDTO addCleaningStrategye(@RequestBody @Valid CleaningStrategy cleaningStrategy) {
        return cleaningStrategyService.addCleaningStrategy(cleaningStrategy);
    }
    @ApiOperation(value = "清洗策略修改", notes = "清洗策略修改")
    @PostMapping("updateCleaningStrategy")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_CLEANINGSTRATEGY, content = "清洗策略修改")
    public ResponseDTO updateCleaningStrategy(@RequestBody @Valid CleaningStrategy cleaningStrategy) {
        return cleaningStrategyService.updateCleaningStrategy(cleaningStrategy);
    }
    @ApiOperation(value = "清洗策略删除", notes = "清洗策略删除")
    @PostMapping("deleteCleaningStrategy")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_CLEANINGSTRATEGY, content = "清洗策略删除")
    public ResponseDTO deleteCleaningStrategy(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return cleaningStrategyService.deleteCleaningStrategy(new_id);
    }
    @ApiOperation(value = "查询所有清洗策略", notes = "查询所有清洗策略")
    @GetMapping("findCleaningStrategyAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_CLEANINGSTRATEGY, content = "查询所有清洗策略")
    public ResponseDTO findCleaningStrategyAll(Integer current, Integer size) {
        return cleaningStrategyService.findCleaningStrategyAll(current,size);
    }
}
